using System;
using System.Collections.Generic;
using System.Drawing;
using RPGOnline.Controls.Map.Layers;

namespace RPGOnline.Controls.Map
{
    public class MapCell
    {
        private DateTime m_lastDrawTime;
        private int m_framesPerSecond = 4;
        private int m_frameToDraw = 0;

        public MapCell()
        {
            Frames = new List<MapCellFrame>();
            m_lastDrawTime = DateTime.Now;
            ObstructionLines = new List<ObstructionLine>();
        }

        public List<MapCellFrame> Frames { get; set; }
        public int FrameToDraw
        {
            get
            {
                TimeSpan elapsedTimeFromLastDraw = DateTime.Now - m_lastDrawTime;

                m_frameToDraw = (int) ((elapsedTimeFromLastDraw.TotalSeconds * m_framesPerSecond) % Frames.Count);

                return m_frameToDraw;
            } 
        }

        public MapCellFrame Frame
        {
            get
            {
                if (Frames.Count == 0)
                    return null;

                return Frames[FrameToDraw];
            }
        }

        public List<ObstructionLine> ObstructionLines { get; private set; }
    }
}